package com.xuchaotong.zk;

import com.xuchaotong.zk.demo.NodeWatcher;
import com.xuchaotong.zk.demo.ZookeeperMgr;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.xml.soap.Node;

/**
 * @author 311633
 * @version 1.0
 * @ClassName:
 * @Description:
 * @date 2017/11/21 14:41
 */
@Component
public class InitWatcherBean implements InitializingBean {
    private static final Logger LOG = LoggerFactory.getLogger(InitWatcherBean.class);

    @PostConstruct
    public void init() {
        try {
            ZookeeperMgr.getInstance().init("127.0.0.1:2181", "", false);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void afterPropertiesSet() throws Exception {
        NodeWatcher nodeWatcher = new NodeWatcher();
        nodeWatcher.monitorMaster();
    }
}
